﻿
Partial Class Login
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        Txt_User.Focus()
    End Sub

    Protected Sub btnLogin_Click(sender As Object, e As EventArgs) Handles Btn_Login.Click
        If Txt_User.Text = "" And Txt_Pass.Text = "" Then
            lblError.Text = "กรุณาตรวจสอบ username or password"
            Exit Sub
        End If

        Dim sql As String
        sql = " select * from user_table where id_picop = '" & Txt_User.Text & "' and PASSWORD_PICOP = '" & Txt_Pass.Text & "'"
        Dim dt As New Data.DataTable

        dt = clsCommand.SQL_exec(sql)
        If dt.Rows.Count > 0 Then
            Session("section") = dt.Rows(0)("section")
            Session("fname") = dt.Rows(0)("firstname")
            Session("lname") = dt.Rows(0)("lastname")
            Session("ID_USER") = dt.Rows(0)("id_user")
        End If

        Response.Redirect("Master/MainMenu.aspx")
    End Sub

    
End Class
